<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiyue" uri="http://www.shiyue.com" %>
<%
String path = request.getContextPath();
%>
<!-- 
	
	2010-07-03 
	教师分组（按照各教师看教师分组）
 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<title>教师分组--学科组</title>
	<link href="<%=path%>/css/index_css.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/css/paging.css">
	<script src="<%=path%>/js/resizeIframe.js" type="text/javascript"></script>
	<script src="<%=path%>/js/syAjax.js" type="text/javascript"></script>
	<script src="<%=path%>/dwr/engine.js"></script>
	<script src="<%=path%>/dwr/util.js"></script>
	<script src="<%=path%>/dwr/interface/shiyueDwr.js"></script>
	<script type="text/javascript">
      //全局变量
      var tdID=null;	//选中TD对象
      var isEditor=1;	//是否为编辑状态 0：可编辑 1：不可编辑
      var currentYear="2010-2011";//当前选中年度
      //点击保存教师所在学科组
      function save(userId,orgId,td)
      {
        //判断是否为当前年度
        if(document.getElementById('year').value=='${applicationScope.currentYear}')
		{
        //判断是否为可编辑状态
      	if(isEditor==0)
      	{
   	    	tdID=td;
         	syAjax.request("post","<%=path%>/saveUserOrgRoleRelationroleAction.action","PORR.id.user.userId="+userId+"&PORR.id.role.roleId=member&currentPage=${currentPage}&PORR.id.organization.organizationId="+orgId,{success:initStageResult,fail:onFail,type:'plain'});

      	}else{
      	  alert("请设为编辑状态!");
      	}
      	}
      	else
      	{
      		alert("不是当前年度，不能进行此操作！");
      	}
      }
      
      function initStageResult(response){
 		if(response=="save")
 		{
 		  tdID.innerHTML="√";
 		}else if(response=="delete")
 		{
 		  tdID.innerHTML="";
 		}
   	  }
   	  
   	  //改变编辑状态
   	  function changeEditor(a)
   	  {
   	    if(isEditor==0)
   	    {
   	    	a.innerHTML="<font color='#000000'>设为编辑状态</font>";
   	    	isEditor=1;
   	    }else{
   	    	a.innerHTML="<font color='red'>设为非编辑状态</font>";
   	    	isEditor=0;
   	    }
   	  }
   	  
   	   function getAllYearCallBack(yearMap) {
        DWRUtil.addOptions("year", yearMap);
        if('${year}'!="")
    	{
    	  document.getElementById('year').value="${year}";
    	}else if('${currentYear}'!="")
    	{
    	  document.getElementById('year').value="${currentYear}";
    	}
    	var objURL="";
		objURL= "<%=path %>/findTeaAndDeporganizationAction.action?orgType=1&years="+document.getElementById('year').value+"&forwardPage=teaToStaffRoom&currentPage=${currentPage}";		
		paging(objURL,pageInfo);
    } 
    
    function tdClick(url)
    {
      window.location.href=url;
    }
    
    var pageInfo = ${shiyue:toJSONWithExclude(pageInfo, "class,pageData")};
	window.onload   =   function(){
	shiyueDwr.getAllYear(getAllYearCallBack);
    	resizeIframe();
	});
	</script>
  </head>
  
  <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" class="f_5">教师分组</td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#9DD12E"></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="bottom" background="<%=path%>/images/sywesp_24.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path%>/images/sywesp_18.gif" class="f_6" onclick="tdClick('findTeaAndDeporganizationAction.action?years=${currentYear}&orgType=2&forwardPage=teaToDepartment');" style="cursor:pointer;">部门分组</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="5" align="left">&nbsp;</td>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path%>/images/sywesp_18.gif" class="f_6" onclick="tdClick('<%=path %>/findUserGradeGradeAndClassAction.action?year=${currentYear }&forwardPage=teaToGrade');" style="cursor:pointer;">年级分组</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="5" align="left">&nbsp;</td>
            <td width="100" align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path%>/images/sywesp_25.gif" class="f_9">教研组分组</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"><br></td>
              </tr>
            </table></td>
            <td align="left">&nbsp;</td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left" valign="top" class="tb_8 border_2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="25" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="38%" align="left">按照教师看分组 ┆ <a href="findTeaAndDeporganizationAction.action?orgType=1&years=${currentYear }&forwardPage=staffRoomToTea">按照教研组看分组</a> <br /></td>
                <td width="46%" align="right" valign="top">按年度查询：
                  <label>
                  <select name="select2" id="year" onchange="tdClick('<%=path %>/findTeaAndDeporganizationAction.action?orgType=1&years='+this.value+'&forwardPage=teaToStaffRoom');">
                  </select>
                  </label></td>
                <td width="16%" style="border:solid #CCCCCC 1px;" align="right" class="f_4" onclick="changeEditor(this);" style="cursor:pointer;"><font color="#000000">设为编辑状态</font></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DCDCDC">
              <tr>
                <td width="11%" height="30" align="center" bgcolor="#DBE9F6" class="f_4">姓名</td>
                  <c:if test="${! empty requestScope.AllOrganizationByType}">
                    <c:forEach items="${requestScope.AllOrganizationByType}" var="staff">
                		<td width="11%" align="center" bgcolor="#DBE9F6" class="f_4">${staff.name }</td>
                	</c:forEach>
                  </c:if>
              </tr>
              <c:choose>
                <c:when test="${! empty requestScope.UserList}">
                  <c:forEach items="${requestScope.UserList}" var="user">
	              <tr>
	                <td height="30" bgcolor="#FFFFFF" align="center" nowrap="nowrap"> &nbsp;${user.name }</td>
	                <c:forEach items="${AllOrganizationByType}" var="org">
	                	<td align="center" bgcolor="#FFFFFF" class="f_3" onclick="save('${user.userId}','${org.organizationId}',this)"  onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''" style="cursor:pointer;" title="点击设定教师分组">
	                		<c:if test="${! empty mapList}">
	                				<c:set value='${user.userId}${org.organizationId}' var="UserOrg" />
		                				<c:if test="${! empty requestScope.mapList[UserOrg]}">
		                					√
		                				</c:if>
                		 	</c:if>
	                	</td>
	                </c:forEach>
	              </tr>
             	 </c:forEach>
                </c:when>
                <c:otherwise><tr><td align="center"><font color="#FFFFFF">无相关信息</font></td></tr></c:otherwise>
              </c:choose>
        </table>
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="30" align="right"><shiyue:paging/></td>
            </tr>
          </table></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
   </tr>
  </table>
  </body>
</html>
